package until

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"strconv"

	"com.jiaguyu/logger"
)

func GetQueryInt64(ctx *gin.Context, key string) (value int64, err error) {
	idstr, ok := ctx.GetQuery(key)
	if !ok {
		err = fmt.Errorf("参数错误key:%s", key)
		logger.Error("参数错误:err=%s", key)
		return
	}

	//将id转为int64
	value, err = strconv.ParseInt(idstr, 10, 64)
	if err != nil {
		logger.Error("参数错误:err=%V,id:%V\n", err, value)
		err = fmt.Errorf("参数错误key:%s", key)
		return
	}
	return
}
